package com.cn.ysf.newbeemall.service.Impl;

import com.cn.ysf.newbeemall.mapper.NewBeeMallGoodsMapper;
import com.cn.ysf.newbeemall.pojo.TbNewbeeMallGoodsInfo;
import com.cn.ysf.newbeemall.service.NewBeeMallGoodsService;
import com.cn.ysf.newbeemall.util.PageQueryUtil;
import com.cn.ysf.newbeemall.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ysf
 * @date 2019/12/10 16:01
 */
@Service
public class NewBeeMallGoodsServiceImpl implements NewBeeMallGoodsService {

    @Resource
    private NewBeeMallGoodsMapper newBeeMallGoodsMapper;

    /**
     * 根据前台传的商品id从后台查询该商品的信息
     * @param goodsId
     * @return
     */
    @Override
    public TbNewbeeMallGoodsInfo selectByPrimaryKey(Long goodsId) {
        return newBeeMallGoodsMapper.selectByPrimaryKey(goodsId);
    }

    /**
     * 后台分页
     * @param pageQueryUtil
     * @return
     */
    @Override
    public PageResult getNewBeeMallGoodsPage(PageQueryUtil pageUtil) {
        List<TbNewbeeMallGoodsInfo> goodsInfoList=newBeeMallGoodsMapper.findNewBeeMallGoodsList(pageUtil);
        Long total=newBeeMallGoodsMapper.getTotalNewBeeMallGoodsBySearch(pageUtil);
        PageResult pageResult=new PageResult(goodsInfoList,total,pageUtil.getLimit(),pageUtil.getPage());
        return pageResult;
    }
}
